const KEY = 'My_token'
export const setToken = (token) => {
  localStorage.setItem(KEY, token)
}

export const getToken = () => {
  return localStorage.getItem(KEY)
}

export const removeToken = () => {
  localStorage.removeItem(KEY)
}

// 将数据中label改成text，在创建空数组children
export const dataHandle = (data) => {
  data = JSON.parse(JSON.stringify(data).replace(/label*/g, 'text'))
  
  data.children.forEach((item) => {
    if (!Object.keys(item).includes('children')) {
      item.children = []
    }
  })
  return data
}

export const LabelOrText = (data) => {
  data = JSON.parse(JSON.stringify(data).replace(/label*/g, 'text'))
  return data
}


